from enum import Enum


class Module(Enum):
    Backtesting = "BT回测-Backtesting"
    FactorAnalysis = "因子分析-Factor Analysis"
    Fighting = "模型综合应用-Fighting"
    KChart = "K线图-KChart"
    DownloadMKData = "数据下载-Download MKData"
    DataBridge = "数据桥-Data Bridge"
    MachineLearning = "机器学习-Machine Learning"
    Running = "运行日志-Running"
    Operate = "操作日志-Operate"
    FileInfo = "数据信息-File Info"
    FileAction = "文件动态-File Action"
    GenModel = "模型生成器-Gen Model"
    FactorLibraryReport = "因子库报告-Factor Library Report"
    DataMerge = "数据合并-Data Merge"
    RevenueCalculate = "收益测算-Revenue Calculate"
    OrderIntegration = "订单整合-Order Integration"
    MessageOrder = "消息订单化-Message Order"
    BacktestingVisualization = "回测可视化-Backtesting Visualization"
    SectorGuide = "板块指南-Sector Guide"
    ComparisonChart = "对比图-Comparison Chart"


class LabelMember(Enum):
    ModelName = "模型名称"
    TextBox = "文本框"
    DataName = "数据名称"
    SymbolName = "标的名称"
    TradingVariety = "交易品种"
    FightingMode = "执行模式"
    SendEmail = "发送邮件"
    RunMode = "运行模式"
    KFactor = "K线因子"
    VolFactor = "Vol因子"
    Factor1 = "因子集1"
    Factor2 = "因子集2"
    FactorName = "因子名称"
    TargetName = "标签名称"
    ExistingFactor = "既有因子"
    StrategyName = "策略名称"
    ResearchPlan = "研究方案"
    EngineClass = "引擎类"
    ResultFolder = "结果文件夹"
    MkDataFolder = "行情文件夹"
    KInterval = "K线级别"
    Count = "数量"
    StartTime = "开始时间"
    EndTime = "结束时间"
    RetryTime = "重试次数"
    SoftwarePath = "软件路径"
    # --- addition module ---
    Cost = "成本"
    ProfitProbability = "正向概率"
    ProfitCostMultiple = "正向倍数"
    LossCostMultiple = "反向倍数"

    OrderFile = "订单文件"
    MkDataFile = "行情文件"

    MessageFile = "消息文件"
    HoldTime = "持仓时间"

    EquityFile = "净值文件"
    TradeFile = "交易文件"

    SectorFile = "板块文件"
    SectorName = "板块名称"


class ButtonMember(Enum):
    Ok = "确认"
    Run = "运行"
    OnlyData = "仅数据"
    OnlyReport = "仅报告"
    Stop = "停止"
    Draw = "绘制"


class WidgetCategory(Enum):
    Label = "label"
    Entry = "entry"
    Combobox = "combobox"
    Filedialog = "filedialog"
    CheckButton = "check_button"
    ScrolledText = "scrolled_text"
    Button = "button"


class DataFolder(Enum):
    Action = "action"
    MkLive = "MkLive"
    MkFtLive = "MkFtLive"
    MkFtSgLive = "MkFtSgLive"
    Mk = "Mk"
    MkFt = "MkFt"
    MkFtSg = "MkFtSg"
    Temp = "temp"


class DataCategory(Enum):
    MkLive = "MkLive"
    MkFtLive = "MkFtLive"
    MkFtSgLive = "MkFtSgLive"
    Mk = "Mk"
    MkFt = "MkFt"
    MkFtSg = "MkFtSg"
    Equity = "equity"
    Order = "order"
    Trade = "trade"
    Message = "message"
    Sector = "sector"


class DataDefGroup(Enum):
    MkLive = "m_live_data_name_ls"
    MkFtLive = "mf_live_data_name_ls"
    MkFtSgLive = "mfs_live_data_name_ls"
    Mk = "m_data_name_ls"
    MkFt = "mf_data_name_ls"
    MkFtSg = "mfs_data_name_ls"
    Equity = "equity_ls"
    Order = "order_ls"
    Trade = "trade_ls"
    BTSName = "bt_strategy_name_ls"
    DDQMName = "ddq_message_name_ls"
    DDQSName = "ddq_simulate_name_ls"
    DDQRName = "ddq_real_name_ls"
    DDQMLEName = "ddq_machine_learning_engine_name_ls"
    BSummary = "backtest_summary_ls"
    FSummary = "factor_summary_ls"
    FHTSummary = "fighting_summary_ls"
    FName = "factor_name_ls"


class ResultFolder(Enum):
    BT = "backtesting"
    FA = "factor_analysis"
    FHT = "fighting"
    FHT_LM = "fighting-live_message"
    FHT_HM = "fighting-history_message"
    FHT_LS = "fighting-live_simulate"
    FHT_HS = "fighting-history_simulate"
    FHT_LR = "fighting-live_real"
    MLE = "machine_learning_engine"
    ADD = "addition_module"


class LogName(Enum):
    Running = "RunningLog"
    Operate = "Operate"
    FileAction = "FileAction"
    FileInfo = "FileInfo"
    Operate_run_status = "Operate run status"


class KLinesWinCategory(Enum):
    KLines = "k_chart"
    Volume = "volume"
    Factor = "factor"


class FactorShowCategory(Enum):
    Bar = "bar"
    Volume = "volume"
    Line = "line"
    Point = "point"
    Tank = "tank"
    Buy = "buy"
    Sell = "sell"


class Interval(Enum):
    """
    Interval of bar support.
    """
    SECOND = "1s"
    SECOND2 = "2s"
    SECOND3 = "3s"
    SECOND4 = "4s"
    SECOND5 = "5s"
    SECOND6 = "6s"
    SECOND10 = "10s"
    SECOND12 = "12s"
    SECOND15 = "15s"
    SECOND20 = "20s"
    SECOND30 = "30s"
    MINUTE = "1m"
    MINUTE2 = "2m"
    MINUTE3 = "3m"
    MINUTE4 = "4m"
    MINUTE5 = "5m"
    MINUTE6 = "6m"
    MINUTE10 = "10m"
    MINUTE12 = "12m"
    MINUTE15 = "15m"
    MINUTE20 = "20m"
    MINUTE30 = "30m"
    HOUR = "1h"
    HOUR2 = "2h"
    HOUR3 = "3h"
    HOUR4 = "4h"
    HOUR6 = "6h"
    HOUR8 = "8h"
    HOUR12 = "12h"
    DAILY = "1d"
    WEEKLY = "1w"
    TICK = "tick"


class Exchange(Enum):
    """
    Exchange.
    """
    # Chinese
    CFFEX = "CFFEX"         # China Financial Futures Exchange
    SHFE = "SHFE"           # Shanghai Futures Exchange
    CZCE = "CZCE"           # Zhengzhou Commodity Exchange
    DCE = "DCE"             # Dalian Commodity Exchange
    INE = "INE"             # Shanghai International Energy Exchange
    GFEX = "GFEX"           # Guangzhou Futures Exchange
    SSE = "SSE"             # Shanghai Stock Exchange
    SZSE = "SZSE"           # Shenzhen Stock Exchange
    BSE = "BSE"             # Beijing Stock Exchange
    SGE = "SGE"             # Shanghai Gold Exchange
    WXE = "WXE"             # Wuxi Steel Exchange
    CFETS = "CFETS"         # CFETS Bond Market Maker Trading System
    XBOND = "XBOND"         # CFETS X-Bond Anonymous Trading System

    # Global
    SMART = "SMART"         # Smart Router for US stocks
    NYSE = "NYSE"           # New York Stock Exchange
    NASDAQ = "NASDAQ"       # Nasdaq Exchange
    ARCA = "ARCA"           # ARCA Exchange
    EDGEA = "EDGEA"         # Direct Edge Exchange
    ISLAND = "ISLAND"       # Nasdaq Island ECN
    BATS = "BATS"           # Bats Global Markets
    IEX = "IEX"             # The Investors Exchange
    AMEX = "AMEX"           # American Stock Exchange
    TSE = "TSE"             # Toronto Stock Exchange
    NYMEX = "NYMEX"         # New York Mercantile Exchange
    COMEX = "COMEX"         # COMEX of CME
    GLOBEX = "GLOBEX"       # Globex of CME
    IDEALPRO = "IDEALPRO"   # Forex ECN of Interactive Brokers
    CME = "CME"             # Chicago Mercantile Exchange
    ICE = "ICE"             # Intercontinental Exchange
    SEHK = "SEHK"           # Stock Exchange of Hong Kong
    HKFE = "HKFE"           # Hong Kong Futures Exchange
    SGX = "SGX"             # Singapore Global Exchange
    CBOT = "CBT"            # Chicago Board of Trade
    CBOE = "CBOE"           # Chicago Board Options Exchange
    CFE = "CFE"             # CBOE Futures Exchange
    DME = "DME"             # Dubai Mercantile Exchange
    EUREX = "EUX"           # Eurex Exchange
    APEX = "APEX"           # Asia Pacific Exchange
    LME = "LME"             # London Metal Exchange
    BMD = "BMD"             # Bursa Malaysia Derivatives
    TOCOM = "TOCOM"         # Tokyo Commodity Exchange
    EUNX = "EUNX"           # Euronext Exchange
    KRX = "KRX"             # Korean Exchange
    OTC = "OTC"             # OTC Product (Forex/CFD/Pink Sheet Equity)
    IBKRATS = "IBKRATS"     # Paper Trading Exchange of IB

    # 占位
    DDQ = "DDQ"


class Variety(Enum):
    Stock = "股票"
    Future = "期货"
    Virtual = "数字货币"


class Direction(Enum):
    """
    Direction of order/trade/position.
    """
    LONG = "多"
    SHORT = "空"
    MIDDLE = "中"
    NET = "净"


class SigType(Enum):
    Buy = "buy"
    Sell = "sell"
    Mess = "message"


class Level(Enum):
    """
    Level of message notification
    """
    Normal = "普通"
    Informational = "提示"
    Critical = "重要"


class Status(Enum):
    """
    Order status.
    """
    SUBMITTING = "提交中"
    NOTTRADED = "未成交"
    PARTTRADED = "部分成交"
    ALLTRADED = "全部成交"
    CANCELLED = "已撤销"
    REJECTED = "拒单"


class OrderType(Enum):
    """
    Order type.
    """
    LIMIT = "限价"
    MARKET = "市价"
    STOP = "STOP"
    FAK = "FAK"
    FOK = "FOK"
    RFQ = "询价"


class Offset(Enum):
    """
    Offset of order/trade.
    """
    NONE = ""
    OPEN = "开"
    CLOSE = "平"
    CLOSETODAY = "平今"
    CLOSEYESTERDAY = "平昨"


class Model(Enum):
    """模型相关参数"""
    MODEL_PRE = "model"
    DefaultSymbol = "DDQ001"


class Code(Enum):
    """
    Some constant of code.
    """
    lock_file_name = "sample.lock"


class FightingMode(Enum):
    """fighting的运行模式"""
    LiveMessage = "实盘数据Message模式"
    HistoryMessage = "回测数据Message模式"
    LiveSimulate = "实盘数据Simulate模式"
    HistorySimulate = "回测数据Simulate模式"
    LiveReal = "实盘数据Real模式"


class SendEmailMode(Enum):
    """邮件数据的发送模式"""
    OneMode = "逐个模式"
    GroupMode = "集数模式"


class SendEmailSignal(Enum):
    """发送电子邮件信号"""
    Allow = "允许"
    Close = "关闭"


class DataFlowMode(Enum):
    """K线图的数据模式"""
    Live = "实时"
    His = "历史"
